<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use App\Task;
use App\Grow as G;

class Grow extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'grow';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'gei ke hu zhang li';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //给今天需要涨利的用户发钱
        $today = date('Y-m-d');
        $tasks = Task::where('enddate','>=',$today)->get();
        $data = [];
        $i=0;
        foreach ($tasks as $task) {
            $data[$i]['bid'] = $task->bid;
            $data[$i]['uid'] = $task->uid;
            $data[$i]['title'] = $task->title;
            $data[$i]['interest'] = $task->interest;
            $data[$i]['growdate'] = $today;
            $i+=1;
        }
        G::insert($data);
    }
}
